/**
 * meiguang8.com
 * Copyright (C) 2016-2019 All Rights Reserved.
 */
package com.yuanchuang.yp.mall.web.admin.controller;

import com.alibaba.fastjson.JSONObject;
import com.yuanchuang.yp.mall.web.admin.common.utils.AesEncodeUtil;
import com.yuanchuang.yp.mall.web.admin.entity.AuthUserDO;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * class_name: BaseController
 * package: com.yuanchuang.yp.mall.web.admin.controller
 * describe: TODO
 * @author: yuanyuan.zhu
 * creat_date: 2019/7/12
 * creat_time: 11:55
 **/
public abstract class BaseController {


    public AuthUserDO getAuthUser(HttpServletRequest request){
        String authorization = request.getHeader("Authorization");
        try {
            authorization =  URLDecoder.decode(authorization, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String userInfo = AesEncodeUtil.decrypt(authorization);
        return  JSONObject.parseObject(userInfo, AuthUserDO.class);
    }
}
